<?php
/**
 * Prado Portal.
 *
 * @author Steen Rabol <steen.rabol@gmail.com>
 * @link http://www.pradoportal.dk/
 * @copyright Copyright &copy; 2006,2007,2008 Steen Rabol
 * @license http://www.pradoportal.dk
 * @version $Id: InActiveLogin.php 378 2010-12-21 09:29:24Z steen.rabol $
 *
 */

class InActiveLogin extends PortalSystemPage
{
	public function onInit($param)
	{
		parent::onInit($param);
		$this->Title = $this->Application->Parameters['SiteTitle'] . " - ". Prado::localize("In active login");
		$this->InActiveMsg->Text = Prado::localize("You have not been active for {num_minutes} minutes and have therefore been logged out.", array('num_minutes' => $this->Application->Parameters['LoginExpire']));
		$this->Page->getClientScript()->registerFocusControl($this->Username);
	}

	public function validateUser($sender,$param)
	{
		$authManager	= $this->Application->getModule('auth');
		if(!$authManager->login($this->Username->Text,$this->Password->Text))
		{
			$param->IsValid	= false;
		}
	}

	public function loginButtonClicked($sender,$param)
	{
		if($this->Page->IsValid)
		{
			$this->gotoDefaultPage();
		}
	}

	public function checkUsername($sender,$param)
	{
		$username=$this->Username->Text;

		$id = $this->DataAccess->createCommand("select * from tblusers where name='$username'")->queryRow();
		if($id)
		{
			$param->IsValid = true;
		}
		else
		{
			$param->IsValid = false;
		}
	}
}
?>